home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / msoftapp.zip / MAINFRM.CPP < prev    next >
C/C++ Source or Header  |  1993-06-01  |  5KB  |  195 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "diblook.h"
  15.  
  16. #include "mainfrm.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMainFrame
  25.  
  26. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  27.  
  28. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  29.     //{{AFX_MSG_MAP(CMainFrame)
  30.     ON_WM_CREATE()
  31.     ON_WM_PALETTECHANGED()
  32.     ON_WM_QUERYNEWPALETTE()
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // arrays of IDs used to initialize control bars
  38.  
  39. // toolbar buttons - IDs are command buttons
  40. static UINT BASED_CODE buttons[] =
  41. {
  42.     // same order as in the bitmap 'toolbar.bmp'
  43.     ID_FILE_NEW,
  44.     ID_FILE_OPEN,
  45.     ID_FILE_SAVE,
  46.         ID_SEPARATOR,
  47.     ID_EDIT_CUT,
  48.     ID_EDIT_COPY,
  49.     ID_EDIT_PASTE,
  50.         ID_SEPARATOR,
  51.     ID_FILE_PRINT,
  52.     ID_APP_ABOUT,
  53. };
  54.  
  55. static UINT BASED_CODE indicators[] =
  56. {
  57.     ID_SEPARATOR,           // status line indicator
  58.     ID_INDICATOR_CAPS,
  59.     ID_INDICATOR_NUM,
  60.     ID_INDICATOR_SCRL,
  61. };
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CMainFrame construction/destruction
  65.  
  66. CMainFrame::CMainFrame()
  67. {
  68. }
  69.  
  70. CMainFrame::~CMainFrame()
  71. {
  72. }
  73.  
  74. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  75. {
  76.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  77.         return -1;
  78.  
  79.     if (!m_wndToolBar.Create(this) ||
  80.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  81.         !m_wndToolBar.SetButtons(buttons,
  82.           sizeof(buttons)/sizeof(UINT)))
  83.     {
  84.         TRACE("Failed to create toolbar\n");
  85.         return -1;      // fail to create
  86.     }
  87.  
  88.     if (!m_wndStatusBar.Create(this) ||
  89.         !m_wndStatusBar.SetIndicators(indicators,
  90.           sizeof(indicators)/sizeof(UINT)))
  91.     {
  92.         TRACE("Failed to create status bar\n");
  93.         return -1;      // fail to create
  94.     }
  95.  
  96.     return 0;
  97. }
  98.  
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CMainFrame commands
  102.  
  103.  
  104. void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd)
  105. {
  106.     CMDIFrameWnd::OnPaletteChanged(pFocusWnd);
  107.  
  108.     // always realize the palette for the active view
  109.     CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  110.     if (pMDIChildWnd == NULL)
  111.         return; // no active MDI child frame
  112.     CView* pView = pMDIChildWnd->GetActiveView();
  113.     ASSERT(pView != NULL);
  114.  
  115.     // notify all child windows that the palette has changed
  116.     SendMessageToDescendants(WM_DOREALIZE, (WPARAM)pView->m_hWnd);
  117. }
  118.  
  119.  
  120.  
  121. BOOL CMainFrame::OnQueryNewPalette()
  122. {
  123.     // always realize the palette for the active view
  124.     CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  125.     if (pMDIChildWnd == NULL)
  126.         return FALSE; // no active MDI child frame (no new palette)
  127.     CView* pView = pMDIChildWnd->GetActiveView();
  128.     ASSERT(pView != NULL);
  129.  
  130.     // just notify the target view
  131.     pView->SendMessage(WM_DOREALIZE, (WPARAM)pView->m_hWnd);
  132.     return TRUE;
  133. }
  134.  
  135. /////////////////////////////////////////////////////////////////////////////
  136. // CNewFrame
  137.  
  138. IMPLEMENT_DYNCREATE(CNewFrame, CMDIChildWnd)
  139.  
  140. CNewFrame::CNewFrame()
  141. {
  142. }
  143.  
  144. CNewFrame::~CNewFrame()
  145. {
  146. }
  147.  
  148. BOOL CNewFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
  149. {
  150.     return m_wndSplitter.Create(this,
  151.         2, 2,        // TODO: adjust the number of rows, columns
  152.         CSize(10, 10),    // TODO: adjust the minimum pane size
  153.         pContext);
  154. }
  155.  
  156. BEGIN_MESSAGE_MAP(CNewFrame, CMDIChildWnd)
  157.     //{{AFX_MSG_MAP(CNewFrame)
  158.         // NOTE - the ClassWizard will add and remove mapping macros here.
  159.     //}}AFX_MSG_MAP
  160. END_MESSAGE_MAP()
  161.  
  162. /////////////////////////////////////////////////////////////////////////////
  163. // CNewFrame message handlers
  164.  
  165. /////////////////////////////////////////////////////////////////////////////
  166. // CMySplitter
  167.  
  168. IMPLEMENT_DYNCREATE(CMySplitter, CMDIChildWnd)
  169.  
  170. CMySplitter::CMySplitter()
  171. {
  172. }
  173.  
  174. CMySplitter::~CMySplitter()
  175. {
  176. }
  177.  
  178. BOOL CMySplitter::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
  179. {
  180.     return m_wndSplitter.Create(this,
  181.         2, 2,        // TODO: adjust the number of rows, columns
  182.         CSize(10, 10),    // TODO: adjust the minimum pane size
  183.         pContext);
  184. }
  185.  
  186. BEGIN_MESSAGE_MAP(CMySplitter, CMDIChildWnd)
  187.     //{{AFX_MSG_MAP(CMySplitter)
  188.         // NOTE - the ClassWizard will add and remove mapping macros here.
  189.     //}}AFX_MSG_MAP
  190. END_MESSAGE_MAP()
  191.  
  192. /////////////////////////////////////////////////////////////////////////////
  193. // CMySplitter message handlers
  194.  
  195.